package com.prs.crm.action.sms;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;

import com.prs.crm.domain.sms.SmsReceive;
import com.prs.crm.service.sms.SmsReceiveService;

public class SmsReceiveAction extends BaseAction{
	private SmsReceive smsReceive;
	private SmsReceiveService smsReceiveService;
	private PaginationSupport pagination;
	private Integer[] ids;
	
	@Action("listSmsReceive")
	public String listSmsReceive() {
		DetachedCriteria criteria = this.getPaginationHelper().createQuery(SmsReceive.class);
		criteria.addOrder(Order.desc("recordTime"));
		pagination = this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getSmsReceiveService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
	@Action("viewSmsReceive")
	public String viewSmsReceive() {
		return SUCCESS;
	}
	
	@Action(value="removeSmsReceive",results={@Result(name="success",type="redirect",location="listSmsReceive"),
			@Result(name="error",type="chain",location="listSmsReceive")})
	public String removeSmsReceive() {
		if(ids == null) {
			this.addActionError("请选择要删除的短信");
			return ERROR;
		}
		this.getSmsReceiveService().batchRemove(ids);
		return SUCCESS;
	}
	
	public SmsReceive getSmsReceive() {
		return smsReceive;
	}
	public void setSmsReceive(SmsReceive smsReceive) {
		this.smsReceive = smsReceive;
	}
	public SmsReceiveService getSmsReceiveService() {
		return smsReceiveService;
	}
	public void setSmsReceiveService(SmsReceiveService smsReceiveService) {
		this.smsReceiveService = smsReceiveService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	
}
